using System;
using System.Windows.Forms;
using Pegasus.Windows.Forms;
using RollManager.Library.Utils;

namespace RollManager.Library.Dialogs
{
    public partial class ChooseServerGroupDialog : FormEx
    {
        public ServerGroup SelectedServerGroup
        {
            get
            {
                return (ServerGroup) serverGroupBox.SelectedItem;
            }
        }

        public ChooseServerGroupDialog() : base( "rollManagerConfig.chooseServerGroupDialog" )
        {
            InitializeComponent();

            serverGroupBox.DataSource = Database.GetServerGroups();
            serverGroupBox.DisplayMember = ServerGroup.NAME_PROPERTY;
        }

        private void ChooseFolderDialog_FormClosing( object sender, FormClosingEventArgs e )
        {
            if( serverGroupBox.SelectedItem == null && DialogResult == DialogResult.OK )
            {
                e.Cancel = true;
            }
        }

        private void okButton_Click( object sender, EventArgs e )
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void cancelButton_Click( object sender, EventArgs e )
        {
            Close();
        }
    }
}